#include <common.h>
#include <memory/paddr.h>


word_t vaddr_read(vaddr_t addr, int len) {
  return paddr_read(addr, 4);
}

void vaddr_write(vaddr_t waddr, word_t wdata, char wmask) {
	if(wmask == 0x9) paddr_write(waddr,1,wdata);//byte
	else if(wmask == 0xB) paddr_write(waddr,2,wdata);//half-word
	else paddr_write(waddr,4,wdata);//word

}


uint32_t dummy[100] = {
	0x00000413,
	0x00009117,
	0xffc10113,
	0x00c000ef,
	0x00000513,
	0x00008067,
	0xff410113,
	0x00000517,
	0x01c50513,
	0x00112423,
	0xfe9ff0ef,
	0x00050513,
	0x00100073,
	0x0000006f
};

extern "C" int inst_read(int raddr){
	return paddr_read(raddr,4);
}

extern "C" void inst_write(int waddr, int wdata){
	paddr_write(waddr,4,wdata);
}


extern "C" int data_read(int raddr){
	//printf("DR:%#010x\n",raddr);
	return vaddr_read(raddr,4);
}

extern "C" void data_write(int waddr, int wdata, char wmask){
	//printf("DW:%#010x,%#010x,%#010x\n",waddr,wdata,wmask);
	vaddr_write(waddr,wdata,wmask);	
}

